function y = fitnessfun(P)
global Xarg Yarg;
%function where have to be implemented the fitness function in other words
%the function to be minimized.

%N cities in the data set
N = size(Xarg,2);

%calculate features F from X using random parameters P
[FY, F] = featureProgram(Yarg ,Xarg, reshape(P,N,2));

%linear regression to find optimal prediction model parameters
% arguments: (Features, Target,Iterations,Learning Rate, Regularization Factor)
% Learning Rate ALFA
%return [optimumParameters finalcost]
[W, wCost] = linearRegressionModel(F, FY, 400, 0.01, 1);

%get the number of examples in the data set
M = size(F,1);

%add the intercepet term
F = [ones(M,1), F];

%make the linear prediction
H = F * W;

%calculate the cost
cost = (1/(2*M)) * ( sum((H - FY) .^ 2));

y = cost;

end

